package br.com.forwardsms.load;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import android.app.Activity;
import android.content.res.Resources;
import android.content.res.Resources.NotFoundException;
import br.com.forwardsms.ForwardSmsActivity;
import br.com.forwardsms.R;

public class LoadMessage {
	private ForwardSmsActivity activity;

	public LoadMessage(ForwardSmsActivity activity){
		this.activity = activity;
	}
	
	public void displayMessage(){
		Resources resources = this.activity.getResources();
		try {
		    InputStream rawResource = resources.openRawResource(R.raw.message_default);
		    Properties properties = new Properties();
		    properties.load(rawResource);
		    this.activity.setTitlle(properties.getProperty("title"));
		    this.activity.setPhone(properties.getProperty("phone"));
		    this.activity.setText(properties.getProperty("text"));
		} catch (NotFoundException e) {
		    System.err.println("Did not find raw resource: "+e);
		} catch (IOException e) {
		    System.err.println("Failed to open microlog property file");
		}

	}
}
